package com.org.controller.unlock;

import com.org.mapper.UserMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * @author Rainy-Heights
 * @version 1.0
 * @Date 2023/3/3 17:28
 */
@Controller
@RequestMapping("/unlock")
public class LockController {
    @Resource
    UserMapper userMapper;
     @RequestMapping(value = "lock-screen",method = RequestMethod.GET)
    public String lock(){
        return "/lock-screen";
    }


    @RequestMapping(value = "unlock",method = RequestMethod.POST)
    public String unlock(@RequestParam(value = "password",defaultValue = "21") String password){
       String pwd=password;
       if (userMapper.getLoginByPwd(pwd)!=null){
           return "redirect:/index";//使用重定向才可以实现正常跳转
       }else {
        return "redirect:/lock-screen" ;
       }
    }
}
